package doublePtr

import (
	"math"
)

/*
时间复杂度:O(N)
空间复杂度:O(1)
*/

func subSort(array []int) []int {
	maxVal := math.MinInt32
	minVal := math.MaxInt32
	n := len(array)
	start, end := -1, -1
	for i, v := range array {
		if maxVal <= v {
			maxVal = v
		} else {
			end = i
		}

		if minVal >= array[n-1-i] {
			minVal = array[n-1-i]
		} else {
			start = n - 1 - i
		}
	}
	return []int{start, end}
}
